<template>
    <div class="safeentry">
        <el-switch v-model="reflux" active-text="防逆流开启" inactive-text="防逆流关闭" size="large" class="switch"  @change="handleRefluxChange($event,1)"/>
        <el-switch v-model="capactrl" active-text="电网容量控制开启" inactive-text="电网容量控制关闭" size="large" class="switch" @change="handleRefluxChange($event,2)"/>
        <el-switch v-model="demandctrl" active-text="电网需量控制开启" inactive-text="电网需量控制关闭" size="large" class="switch" @change="handleRefluxChange($event,3)"/>
        <el-switch v-model="tempprotect" active-text="环境温度保护开启" inactive-text="环境温度保护关闭" size="large" class="switch" @change="handleRefluxChange($event,4)"/>
        <el-switch v-model="socprotect" active-text="离网soc保护开启" inactive-text="离网soc保护关闭" size="large" class="switch" @change="handleRefluxChange($event,5)"/>
        <el-switch v-model="overprotect" active-text="单体过压保护开启" inactive-text="单体过压保护关闭" size="large" class="switch" @change="handleRefluxChange($event,6)"/>
        <el-switch v-model="packtempprotect" active-text="电池包过温保护开启" inactive-text="电池包过温保护关闭" size="large" class="switch" @change="handleRefluxChange($event,7)"/>

    </div>
</template>

<script setup>
import { ref } from 'vue';
const props = defineProps({
    Sval: {
        type: Object
    },
    Cval: {
        type: Object
    }
}
)
    const reflux = ref(false);
    const capactrl = ref(false);
    const demandctrl = ref(false);
    const tempprotect = ref(false);
    const socprotect = ref(false);
    const overprotect = ref(false);
    const packtempprotect = ref(false);
    const handleRefluxChange = (val, index) => {
        switch (index) {
            case 1:
                reflux.value = val;
                console.log("防逆流开启:", val);
                break;
            case 2:
                capactrl.value = val;
                console.log("电网容量控制:", val);
                break;
            case 3:
                demandctrl.value = val;
                console.log("电网需量控制:", val);
                break;
            case 4:
                tempprotect.value = val;
                console.log("环境温度保护开启:", val);
                break;
            case 5:
                socprotect.value = val;
                console.log("离网soc保护开启:", val);
                break;
            case 6:
                overprotect.value = val;
                console.log("单体过压保护开启:", val);
                break;
            case 7:
                packtempprotect.value = val;
                console.log("电池包过温保护开启:", val);
                break;
            default:
                break;
        }
    }
</script>
<style  scoped>
.safeentry{
    margin: auto;
    width: 50%;
}

.switch{
    margin-left: 10px;
    width: 300px;
}
</style>
